package servlet;

import dao.GradeDao;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * Created by ssw on 2018/6/16.
 */
public class AddScoreServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String sid=req.getParameter("sid");
        int ggrade=Integer.parseInt(req.getParameter("ggrade"));
        HttpSession session=req.getSession();
        String scid=(String)session.getAttribute("scid");
        GradeDao gradeDao=new GradeDao();
        boolean flag=gradeDao.addScore(scid,sid,ggrade);
        if(flag)
            req.getRequestDispatcher("sgms/lec_setCourseScore.jsp?res=1").forward(req, resp);
        else
            req.getRequestDispatcher("sgms/lec_setCourseScore.jsp?res=0").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
